﻿using AutoMapper;
using Socloudng.BaseService.DataDictionaryManagement.Dto;
using Socloudng.BaseService.JobManagement.Dto;
using Socloudng.BaseService.Models;
using Socloudng.BaseService.OrganizationManagement.Dto;
using Socloudng.BaseService.Systems.AuditLoggingManagement.Dto;
using Socloudng.BaseService.Systems.UserManagement.Dto;
using Volo.Abp.AuditLogging;
using Volo.Abp.Identity;

namespace Socloudng.BaseService;

public class BaseServiceApplicationAutoMapperProfile : Profile
{
    public BaseServiceApplicationAutoMapperProfile()
    {
        /* You can configure your AutoMapper mapping configuration here.
         * Alternatively, you can split your mapping configurations
         * into multiple profile classes for a better organization. */

        CreateMap<IdentityUser, BaseIdentityUserDto>();

        CreateMap<AuditLog, AuditLogDto>()
            .ForMember(t => t.EntityChanges, option => option.MapFrom(l => l.EntityChanges))
            .ForMember(t => t.Actions, option => option.MapFrom(l => l.Actions));
        CreateMap<EntityChange, EntityChangeDto>()
             .ForMember(t => t.PropertyChanges, option => option.MapFrom(l => l.PropertyChanges));

        CreateMap<AuditLogAction, AuditLogActionDto>();
        CreateMap<EntityPropertyChange, EntityPropertyChangeDto>();

        CreateMap<DataDictionary, DictionaryDto>();

        CreateMap<DataDictionaryDetail, DictionaryDetailDto>();

        CreateMap<Organization, OrganizationDto>()
            .ForMember(dto => dto.Label, opt => opt.MapFrom(src => src.Name));

        CreateMap<Job, JobDto>();
    }
}
